<div class="row-fluid post-content">

    <?php echo $this->Form->create(null, array('type' => 'post','enctype'=>'multipart/form-data', 'name' => 'adminForm', 'inputDefaults' => array('label' => false, 'div' => false, 'legend'=> false))); ?>
    <?php echo $this->Form->input('Product.id',array('type'=>'hidden'));?>

    <div class="content-box"><!-- Start Content Box -->
    	<div class="content-box-header">
            <div class="span12 bg-add">
                <div class="span4 bg-sitebar" style="text-align: center;"><p><?php echo lang('add_post');?> <img style="margin-top: -6px;" src="<?php echo DOMAIN;?>images/may.png" /></p></div>
                <div class="span4 bg-sitebar"><p><?php echo lang('san_pham_thiet_ke');?> <input type="radio" id="radiosanpham" name="data[Product][phanloai]" value="0" checked=""/></p></div>
                <div class="span4 bg-sitebar"><p><?php echo lang('su_kien_va_bai_viet');?> <input type="radio" id="raditobaiviet" name="data[Product][phanloai]" value="1" /></p></div>
            </div>
    	</div> <!-- End .content-box-header -->
        <div class="clear"></div>
    	<div class="content-box-content add">
    		<div> <!-- This is the target div. id must match the href of this div's tab -->
                <table class="input">
                    <tr>
                        <td class="span4">
                            <img style="width: 94%;" src="<?php echo DOMAIN;?>images/avartar.png" title="avatar" alt="avatar"/>
                            <div class="clear-main"></div>
                            <?php echo lang('avatar_for_post');?>:<?php echo $this->Form->input('Product.images',array('type'=>'file', 'accept'=>'image/gif,image/jpeg,image/png'));?>
                        </td>
                        <td class="span6" valign="top">
                            <div class="" style="height: 35px;"></div>
                            <table class="span11">
                                <tr>
                                    <td class="span4"><?php echo lang('name_of_post');?></td>
                                    <td><?php echo $this->Form->input('Product.name',array('class'=>'text-input medium-input','maxlength' => '250'));?></td>
                                </tr>
                                <?php /*<tr>
                                    <td><?php echo lang('dang_san_pham');?></td>
                                    <td><?php echo $this->Form->input('Product.typet_id', array('type'=>'select', 'options'=>'', 'empty' => lang('chon_dang_san_pham')));?></td>
                                </tr>*/?>
                                <tr>
                                    <td><?php echo lang('field');?></td>
                                    <td>
                                        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
                                        <?php //echo $this->Form->input('Product.cat_id', array('type'=>'select', 'options'=>$list_cat, 'empty' => lang('select_field')));?>
                                        <script>
                                            function cat($scope){
                                                $scope.list = [
                                                    <?php foreach($listdanhmuc as $va){
                                                        ?>{
                                                            id:<?php echo $va['id'];?>,
                                                            name:'<?php echo str_replace("'","\'",$va['name']);?>',
                                                            child:[
                                                                <?php foreach($va['list'] as $valu){?>{id:<?php echo $valu['Catproduct']['id'];?>, name:'<?php echo str_replace("'","\'",$valu['Catproduct']['name']);?>'},<?php } ?>
                                                                ]
                                                        },<?php
                                                    }?>
                                                ];
                                                $scope.show_this = function(id){
                                                    if($scope.cat_select == id) return 'data[Product][cat_id]';
                                                    else return false;
                                                }
                                                $scope.cat_select = <?php $tmp = reset($listdanhmuc);echo $tmp['id'];?>;
                                            }
                                        </script>
                                        <div ng-app="">
                                            <div ng-controller="cat">
                                                <select ng-model="cat_select">
                                                    <option ng-repeat="one in list" value="{{one.id}}"> -- {{one.name}}</option>
                                                </select>
                                                <select ng-repeat="one2 in list" ng-show="show_this(one2.id)" name="{{show_this(one2.id)}}">
                                                    <option ng-repeat="one3 in one2.child" value="{{one3.id}}"> -- {{one3.name}}</option>
                                                </select>
                                            </div>
                                        </div>
                                        <?php /*
                                        <select id="sanphamthietke" name="data[Product][cat_id]">
                                            <?php
                                                foreach($listdanhmuc as $va){
                                            ?>
                                                <option value="<?php echo $va['id'];?>"> -- <?php echo $va['name'];?></option>
                                                <?php
                                                    foreach($va['list'] as $valu){
                                                ?>
                                                    <option value="<?php echo $valu['Catproduct']['id'];?>"> -- -- <?php echo $valu['Catproduct']['name'];?></option>
                                                <?php }?>
                                            <?php }?>
                                        </select>
                                        */?>
                                        <?php echo $this->Form->input('Product.cat_id1', array('type'=>'select', 'options'=>$list_sukien_baiviet, 'id' => 'baivietthietke', 'empty' => lang('nghanhthietke'), 'style'=> 'display: none;'));?>

                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="span2">
                            <div style="text-align: center;">
                                <img src="<?php echo IMG_URL.'w114/'.$user_login['images'];?>" />
                                <p class="user-fullname">
                                    <?php echo $user_login['fullname'];?>
                                </p>
                                <p class="user-rate">
                                    <?php $_SESSION['point'] = $user_login['point']; echo $this->element('user-star');?>
                                </p>
                                <p class="user-notice">Hãy đăng thật chi tiết để sản phẩm của bạn được chứ ý hơn</p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div class="clear-content"></div><div class="clear-content"></div>
                            <h2><?php echo lang('mo_ta_chung_sp');?><span class="add_tips"><?php echo lang('mo_ta_chung_sp_t');?></span></h2>
                            <?php  echo $this->Form->input('Product.shortdes',array('type'=>'textarea','class'=>'ckeditor-mini'));?>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <h2><?php echo lang('mo_ta_thong_so_sp');?><span class="add_tips"><?php echo lang('mo_ta_thong_so_sp_t');?></span></h2>
                            <?php  echo $this->Form->input('Product.content',array('type'=>'textarea','class'=>'ckeditor'));?>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <h2><?php echo lang('loi_tac_gia');?><span class="add_tips"><?php echo lang('loi_tac_gia_t');?></span></h2>
                            <?php  echo $this->Form->input('Product.loi_tac_gia',array('type'=>'textarea','class'=>'ckeditor'));?>
                        </td>
                    </tr>
                </table>
                <div class="clear-content"></div><div class="clear-content"></div>
                <p class="span12">
                    <input type="submit" class="btn btn-small btn-primary" value="<?php echo lang('luu_data');?>"/>
                    <input class="btn btn-small" type="reset" value="<?php echo lang('reset_data');?>"/>
                </p>
                <div class="clear-content"></div>
    		</div> <!-- End #tab1 -->
            <a href="#"><div class="to_top">Lên đầu trang <i class="fa fa-arrow-up"></i></div></a>
    	</div> <!-- End .content-box-content -->
    </div> <!-- End .content-box -->
    <?php echo $this->Form->end(); ?>

</div>


<?php echo $this->Html->script('ckeditor/ckeditor'); ?>
<script type="text/javascript">
    $(document).ready(function(){
        $('#radiosanpham').click(function(){
            $('#sanphamthietke').show();
            $('#baivietthietke').hide();
        });
        $('#raditobaiviet').click(function(){
            $('#baivietthietke').show();
            $('#sanphamthietke').hide();
        });
    });


CKEDITOR.editorConfig = function( config ) {
	// Define changes to default configuration here. For example:
	config.language = 'vi';
	//config.uiColor = '#AADC6E';
	config.skin='kama';
	config.enterMode = CKEDITOR.ENTER_BR;
    config.height = 100;

    //config.language = 'en';

	config.filebrowserBrowseUrl 		= '<?php echo DOMAIN;?>js/ckfinder/ckfinder.html';
	config.filebrowserImageBrowseUrl 	= '<?php echo DOMAIN;?>js/ckfinder/ckfinder.html?type=Images';
	config.filebrowserFlashBrowseUrl 	= '<?php echo DOMAIN;?>js/ckfinder/ckfinder.html?type=Flash';
};
</script>
<script type="text/javascript">
$('.ckeditor-mini').each(function(){
    CKEDITOR.replace($(this).attr('name'), {'toolbar': [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [] },
    	{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline'] },
    	{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: ['Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl' ] },
        { name: 'links', items: [] },
    	{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
    	{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
    ] });
});
</script>